package com.qixia.sportsupload.util;

import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;

import java.io.UnsupportedEncodingException;


/**
 * @author Sven
 */

public class TestUtil {

    public static void main(String[] args) throws UnsupportedEncodingException {
//        byte[] key = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded();
//        String key1 = Base64.encode(key);
//        byte[] keyA = key1.getBytes();
//        byte[] keyB = Base64.decode(key1);
//        System.out.println(key1);
//        System.out.println(key);
//        System.out.println(keyA);
//        System.out.println(new String(key1));
//        System.out.println(keyB);
//
//
//        System.out.println(java.util.Base64.getEncoder().encodeToString("balance-token-key".getBytes(StandardCharsets.UTF_8)));
//        System.out.println(new String(Base64.decodeStr("YmFsYW5jZS10b2tlbi1rZXk=")));
//        System.out.println(Base64ConvertUtil.decode("YmFsYW5jZS10b2tlbi1rZXk="));
//        String key2 = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getFormat();
//        String key3 = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).toString();
//        System.out.println(key2);
//        System.out.println(key3);

        //测试前台传账号密码base64加密
                SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, "Urx3axZwn/uzqg/I+vnVOA==".getBytes());
        String enAccount1 = aes.encryptBase64("admin");
//        String enAccount2 = aes.encryptBase64("140100000000");
//        String enAccount3 = aes.encryptBase64("140105000000");
//        String enAccount4 = aes.encryptBase64("610112000000");
//        String enAccount5 = aes.encryptBase64("610000000000");
//        String enAccount = aes.encryptBase64("admin");
        String enPassword = aes.encryptBase64("123456");
        System.out.println(enAccount1);
//        System.out.println(enAccount2);
//        System.out.println(enAccount3);
//        System.out.println(enAccount4);
//        System.out.println(enAccount5);
//        System.out.println(enAccount);
        System.out.println(enPassword);
//        String decAccount = aes.decryptStr(enAccount2);
//        String decPassword = aes.decryptStr(enPassword);
//        System.out.println(decAccount);
//        System.out.println(decPassword);



        //测试密码对称加密
//        String salt = Base64.encode(SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded());
//        SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, Base64.decode(salt));
//        String enPassword = aes.encryptBase64(INIT_PWD);
//        String salt =
//        SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, Base64.decode("8V2rkfawzr9gPdK5kWkF5w=="));
//        String enPassword = aes.encryptBase64("123456");
//        System.out.println(salt);
//        System.out.println(enPassword);

    }

}
